﻿using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics.CodeAnalysis;

namespace SubStationManagement.Server.Models
{
    public class MeasureModule
    {
        [BsonId]
        [BsonRepresentation(BsonType.ObjectId)]
        [Display(Name = "Id")]
        [NotNull]
        public string? Id { get; set; }

        /// <summary>
        /// 获得/设置 标识序号
        /// </summary>
        [Display(Name = "标识序号")]
        [NotNull, Required]
        public string? SerialNumber { get; set; }

        /// <summary>
        /// 获得/设置 设备状态
        /// </summary>
        [Display(Name = "设备状态")]
        public EnumMeasureModuleState ModuleState { get; set; }

        /// <summary>
        /// 获得/设置 IP地址
        /// </summary>
        [Display(Name = "IP地址")]
        [NotNull, Required]
        public string? IpAddress { get; set; }

        /// <summary>
        /// 获得/设置 端口号
        /// </summary>
        [Display(Name = "端口号")]
        [NotNull, Required]
        public int Port { get; set; }

        /// <summary>
        /// 获得/设置 Modbus从站地址
        /// </summary>
        [Display(Name = "Modbus从站地址")]
        [NotNull, Required]
        public int ModbusAddress { get; set; }

        /// <summary>
        /// 获得/设置 电气采样频率
        /// </summary>
        [Display(Name = "电气采样频率")]
        [NotNull, Required]
        public EnumPowerSamplingRate PowerSamplingRate { get; set; }

        /// <summary>
        /// 获得/设置 电气采样频率
        /// </summary>
        [Display(Name = "谐波采样频率")]
        [NotNull, Required]
        public EnumHarmonicSamplingRate HarmonicSamplingRate { get; set; }

        /// <summary>
        /// 获得/设置 Enable
        /// </summary>
        [Display(Name = "启用")]
        public bool Enable { get; set; }
    }

    public enum EnumMeasureModuleState
    {
        /// <summary>
        /// 
        /// </summary>
        [Description("离线")]
        Offline,
        /// <summary>
        /// 
        /// </summary>
        [Description("在线")]
        Online,
        /// <summary>
        /// 
        /// </summary>
        [Description("故障")]
        Error,

    }

    public enum EnumPowerSamplingRate
    {
        /// <summary>
        /// 
        /// </summary>
        [Description("手动")]
        Manuel,

        /// <summary>
        /// 
        /// </summary>
        [Description("每秒")]
        PerSecond,

        /// <summary>
        /// 
        /// </summary>
        [Description("每30秒")]
        Per30Seconds,

        /// <summary>
        /// 
        /// </summary>
        [Description("每分钟")]
        PerMinute,
    }

    public enum EnumHarmonicSamplingRate
    {
        /// <summary>
        /// 
        /// </summary>
        [Description("手动")]
        Manuel,

        /// <summary>
        /// 
        /// </summary>
        [Description("每30秒")]
        Per30Seconds,

        /// <summary>
        /// 
        /// </summary>
        [Description("每分钟")]
        PerMinute,
    }

}
